using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FiltronASP.Modules.Abstracts;
using FiltronASP.Models;
using FiltronASP.Models.DAO;

namespace FiltronASP.Modules
{

    public class textBanner : AbstractModule
    {
        private string galleryName = "bannerImg";
        private string htmlToReturn = String.Empty;

        public override string GenerateContent(FiltronASP.Models.Page page)
        {
            GalleryImageDAO galleryImageDAO = new GalleryImageDAO();
            IQueryable<GalleryImage> imagesCollection = galleryImageDAO.FindByGalleryNameAndPage(this.galleryName, page.page_id);
            if (imagesCollection != null) {
                this.htmlToReturn += "<div class=\"sliderContainer\">";
                this.htmlToReturn += "  <div id=\"slider\" class=\"slider\">";
                this.htmlToReturn += "      <ul>";
                if (imagesCollection.Count() == 1)
                {
                    foreach (GalleryImage singleImage in imagesCollection)
                    {
                        this.htmlToReturn += "<img src=\"" + singleImage.gallery_image_link + "\" alt=\"" + singleImage.gallery_image_info + "\" />";
                    }
                }
                else
                {
                    foreach (GalleryImage singleImage in imagesCollection)
                    {
                        this.htmlToReturn += "<li><a href=\"\"><img src=\"" + singleImage.gallery_image_link + "\" alt=\"" + singleImage.gallery_image_info + "\" /></li></a>";
                    }
                }
                this.htmlToReturn += "      </ul>";
                this.htmlToReturn += "  </div>";
                this.htmlToReturn += "</div>";
            }
            return this.htmlToReturn;
        }
    }
}
